package net.kazed.nextaction.context.activity;

import java.util.HashMap;
import java.util.Map;

/**
 * Choices of period to display started tasks.
 * @author Koert Zeilstra
 */
public enum TaskDatePeriod {

    DAY(1), WEEK(7), MONTH(30);
    
    private static final Map<Integer, TaskDatePeriod> PERIODS;
    
    static {
        PERIODS = new HashMap<Integer, TaskDatePeriod>();
        for (TaskDatePeriod period : TaskDatePeriod.values()) {
            PERIODS.put(period.numberOfDays, period);
        }
    }
    
    private int numberOfDays = 0;
    
    /**
     * Constructor.
     * @param numberOfDays Number of days.
     */
    TaskDatePeriod(int numberOfDays) {
        this.numberOfDays = numberOfDays;
    }
    
    /**
     * @return Number of days.
     */
    public int getNumberOfDays() {
        return numberOfDays;
    }

    /**
     * @param numberOfDays Number of days.
     * @return StartedTasksPeriod of corresponding numberOfDays.
     */
    public static TaskDatePeriod getEnum(Integer numberOfDays) {
        TaskDatePeriod taskType = null;
        if (numberOfDays != null) {
            taskType = PERIODS.get(numberOfDays);
        }
        return taskType;
    }
    
}
